import request from "../utils/request";

const fileNodeApi = {
    mkdir: fileNode => {
        return request({
            url: '/netdisk/fn/mkdir',
            method: 'post',
            data: fileNode
        })
    },
    getListByParentId: parentId => {
        return request({
            url: `/netdisk/fn/list/${parentId}`,
            method: 'get'
        })
    },
    getByPath: path => {
        path = encodeURIComponent(path)
        return request({
            url: `/netdisk/fn?path=${path}`,
            /*url: `/file?path=${path}`,*/
            method: 'get'
        })
    },
    uploadChunk: formData => {
        return request({
            url: '/netdisk/f/upload-chunk',
            method: 'post',
            headers: { "Content-Type": "multipart/form-data" },
            data: formData
        })
    },
    newFileTree: (parentId, nodeList) => {
      return request({
          url: '/netdisk/fn/new-file-tree/' + parentId,
          method: 'post',
          data: nodeList
      })
    },
    createUpload: fileInfo => {
      return request({
          url: '/netdisk/f/create-upload-task',
          method: 'post',
          data: fileInfo
      })
    },
    delById: id => {
        return request({
            url: '/netdisk/fn/del-node/' + id,
            method: 'delete'
        })
    },
    delByIds: ids => {
        return request({
            url: '/netdisk/fn/del-node',
            method: 'post',
            data: ids
        })
    }
}

export default fileNodeApi